package com.fx.smsclient.util;


import com.fx.smsclient.JsonSerializer.CmppDeliverRequestMessageSerializer;
import com.fx.smsclient.JsonSerializer.CmppDeliverResponseMessageSerializer;
import com.fx.smsclient.JsonSerializer.CmppSubmitRequestMessageSerializer;
import com.fx.smsclient.JsonSerializer.CmppSubmitResponseMessageSerializer;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.zx.sms.codec.cmpp.msg.CmppDeliverRequestMessage;
import com.zx.sms.codec.cmpp.msg.CmppDeliverResponseMessage;
import com.zx.sms.codec.cmpp.msg.CmppSubmitRequestMessage;
import com.zx.sms.codec.cmpp.msg.CmppSubmitResponseMessage;

/**
 * @author apple
 */
public class GsonTool {
    static GsonBuilder gsonBuilder = new GsonBuilder()
            .registerTypeAdapter(CmppSubmitRequestMessage.class,new CmppSubmitRequestMessageSerializer())
//            .registerTypeAdapter(CmppSubmitRequestInMessage.class,new CmppSubmitRequestMessageSerializer())
            .registerTypeAdapter(CmppDeliverRequestMessage.class,new CmppDeliverRequestMessageSerializer())
            .registerTypeAdapter(CmppDeliverResponseMessage.class,new CmppDeliverResponseMessageSerializer())
            .registerTypeAdapter(CmppSubmitResponseMessage.class,new CmppSubmitResponseMessageSerializer());

    public static Gson gson = gsonBuilder.create();
    public static String toJson(Object object) {
        return gson.toJson(object);
    }

    public static Object fromJson(String jsonString) {
        return gson.fromJson(jsonString,Object.class);
    }

}
